home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-08-27 | 1.5 KB | 83 lines | [TEXT/PJMM] |
- unit MyGrowZones;
-
- interface
-
- procedure InitGrowZone (size: longInt; alertid: integer);
- procedure FinishGrowZone;
- procedure IdleGrowZone;
- function MemoryCritical: boolean;
- function EnoughSpace (total, contig: longInt): boolean;
-
- implementation
-
- var
- gzh: handle;
- gz_size: longINt;
- lastgzh: handle;
- id: integer;
-
- function MyGrowZone (size: longInt): longInt;
- var
- saved_A5, junk: longInt;
- begin
- saved_A5 := SetCurrentA5;
- if gzh <> nil then begin
- MyGrowZone := GetHandleSize(gzh);
- DisposHandle(gzh);
- gzh := nil;
- end
- else begin
- MyGrowZone := 0;
- end;
- junk := SetA5(saved_A5);
- end;
-
- procedure IdleGrowZone;
- var
- t, c: longInt;
- a: integer;
- begin
- if gzh = nil then begin
- gzh := NewHandle(gz_size);
- if (gzh = nil) and (lastgzh <> nil) and (id > 0) then begin
- SetCursor(arrow);
- a := StopAlert(id, nil);
- end;
- lastgzh := gzh;
- end;
- end;
-
- function MemoryCritical: boolean;
- begin
- MemoryCritical := gzh = nil;
- end;
-
- function EnoughSpace (total, contig: longInt): boolean;
- var
- t, c: longInt;
- begin
- PurgeSpace(t, c);
- EnoughSpace := not MemoryCritical & (t >= total) & (c >= contig);
- end;
-
- {$S Init}
- procedure InitGrowZone (size: longInt; alertid: integer);
- begin
- gz_size := size;
- id := alertid;
- SetGrowZone(@MyGrowZone);
- gzh := nil;
- lastgzh := nil;
- IdleGrowZone;
- end;
-
- {$S Term}
- procedure FinishGrowZone;
- begin
- if gzh <> nil then begin
- DisposHandle(gzh);
- gzh := nil;
- end;
- end;
-
- end.